package com.javalong.affairs.base.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.Toast;

import com.javalong.affairs.base.constant.Constant;
import com.javalong.affairs.base.utils.AppUtils;
import com.javalong.affairs.base.utils.ToastUtils;

/**
 * Created by 杨观回 on 2015/12/29 0029.
 * 按2下退出
 */
public abstract class BackActivity extends BaseActivity {
    public long lastClickTime = 0;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    /*
   * @author ygh 2015/5/12 再按一次退出
   */
    public void oneMoreOut() {
        long now = System.currentTimeMillis();
        if (lastClickTime == 0) {
            Toast.makeText(this, Constant.PRESS_LOGOUT, Toast.LENGTH_SHORT)
                    .show();
        } else {
            long time = now - lastClickTime;
            if (time < Constant.TIME_INTERVAL) {
                // 退出之前，存入userInfo信息
                AppUtils.getInstance().exit();
            } else {
                ToastUtils.showMessage(Constant.PRESS_LOGOUT);
            }
        }
        lastClickTime = now;
    }
}
